# 3  编写一个装饰器，为多个函数加上认证的功能（必须输入用户的账号密码，才能调用这个函数）

FLAG = False


def wrapper(f):
    def inner(*args, **kwargs):
        global FLAG
        if FLAG:
            ret = f(*args, **kwargs)
            return ret
        else:
            username = input('username:')
            password = input('password:')
            if username == '120191080322' and password == '120191080322':
                FLAG = True
                ret = f(*args, **kwargs)
                return ret
            else:
                print('登录失败')

    return inner


@wrapper
def func_1():
    print('func1 is running!')


@wrapper
def func_2():
    print('func2 is running!')


func_1()
func_2()
